﻿@page "{statusCode:int}"
@using Microsoft.AspNetCore.Diagnostics
@using Microsoft.AspNetCore.Mvc

@{ 
    var result = HttpContext.Features.Get<IExceptionHandlerPathFeature>();

    if (!string.IsNullOrEmpty(RouteData.Values["statusCode"]?.ToString()))
    {
        ViewBag.PageTitle = ViewBag.ErrorTitle;
        ViewBag.ErrorCode = "500";
        ViewBag.ErrorTitle = "程序过程中发生错误";
        ViewBag.ErrorPath = result.Path;
        ViewBag.ErrorMessage = result.Error.Message;
    }
    else
    {
        switch (RouteData.Values["statusCode"])
        {
            case 404:
                ViewBag.ErrorCode = "404";
                ViewBag.ErrorTitle = "页面不存在";
                ViewBag.ErrorPath = result.Path;
                ViewBag.ErrorMessage = "抱歉，您访问的页面不存在";
                break;
        }
    }
}

<div class="wrapper">
    <div class="error-box">
        <div class="num">@ViewBag.ErrorCode</div>
        <div class="text">
            @ViewBag.ErrorMessage
        </div>
    </div>
</div>
@section Scripts{
    <script>
        //初始化VUE
        var ve = new Vue({
            el: '#app',
            data: {

            },
            methods: {

            },
        })
    </script>
}